home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 3 / Cream of the Crop 3.iso / comm / prtcs155.zip / MFWD.WPL < prev    next >
Text File  |  1994-01-14  |  4KB  |  141 lines

  1. /**/
  2. v="$VER: Mfwd WPLRX Modem Call Forwarded Packet Switching Williamson 55.00"
  3. /*
  4.     This in entered in Cache,CFG as follows:
  5.     number      number of service
  6.     presess     Mfwd.wplrx $<line> fwdnumber
  7.         where fwdnumber phone number of actual site
  8.     
  9. */
  10. options RESULTS
  11. options failat 99
  12. signal on syntax
  13. signal on halt
  14. signal on ioerr
  15. signal on break_c
  16. signal on break_d
  17.  
  18. if ~show('L', "rexxsupport.library") then
  19.     if ~addlib("rexxsupport.library", 0, -30, 0) then do
  20.          say "Couldn't access support.library !"
  21.         exit 20
  22.     end
  23.  
  24. pragma("W","NULL")
  25. log=show('P','ROOFLOG')
  26. mailer=GetCLip('SHELTER')
  27. l_mailer=lower(mailer)
  28. sv='v'||right(v,5);script="MFWD"
  29. cr    = '\r\n'  /* WPL  */
  30. nl    = '0a'X   /* REXX */
  31. bs    = '08'x
  32. quote = '"'
  33. parse arg line fwdphone 
  34.     trys=0
  35.     do forever
  36.         if trys=3 then do
  37.             Address "LOGPROC" 'PutLog 'l_mailer'wpl' time() line 'Server Connect Timeout after 'trys' trys'
  38.             return 5
  39.         end
  40.         trys=trys+1
  41.         resp=upper(wpl_prompt(3600,cr))
  42.         if resp="" then iterate
  43.         if index(resp,"AUCUNE ENTREE")>0  then do
  44.             Address "LOGPROC" 'PutLog 'l_mailer'wpl' time() line 'Server Busy after 'trys' trys'
  45.             return 5
  46.         end
  47.         if index(resp,"DESTINATION:")>0  then leave
  48.     end
  49.  
  50.     Address "LOGPROC" 'PutLog 'l_mailer'wpl' time() line 'Getting Remote Modem'
  51.     do forever
  52.         if trys=3 then do
  53.             Address "LOGPROC" 'PutLog 'l_mailer'wpl' time() line 'Timeout 'trys' on Remote Modem OK'
  54.             return 5
  55.         end
  56.         trys=trys+1
  57.         resp=upper(wpl_prompt(180,"AT"||cr))
  58.         if resp="" then iterate    
  59.         if index(resp,"DESTINATION:")>0  then do
  60.             Address "LOGPROC" 'PutLog 'l_mailer'wpl' time() line 'Remote modem failed on 'trys
  61.             return 5
  62.         end
  63.         if index(resp,"OK")>0  then leave
  64.     end
  65.     Address "LOGPROC" 'PutLog 'l_mailer'wpl' time() line 'Dialing 'fwdnumber
  66.     resp=wpl_prompt(3600,"ATDT9-,"fwdnumber||cr)
  67.     if index(resp,"CONNECT")=0 then return 0
  68.     Address "LOGPROC" 'PutLog 'l_mailer'wpl' time() line 'Remote connect failed on 'trys
  69. return 5
  70.  
  71. send:
  72.     'Print' quote||arg(1)||quote
  73.     'Send' quote||arg(1)||quote
  74. return
  75.  
  76. wpl_prompt:
  77.     'Print' quote||arg(2)||quote
  78. nprompt:
  79.     'Send' quote||arg(2)||quote
  80. getstring:
  81.     'GetInbound E0 'arg(1)
  82.     'String $(event)'
  83.     if upper(RESULT) = 'CARRIER' then do
  84.         ADdress "LOGPROC" 'PutLog 'l_mailer'wpl' time() line fname 'Dropped Carrier'
  85.         call cleanup
  86.         exit
  87.     end;else if upper(RESULT) = 'LOGIN' then do
  88.         'String $(namebuf)'
  89.         x=(RESULT) 
  90.     end;else x=""
  91. return x
  92.  
  93. lower:
  94. return(bitor(arg(1),'20'x))
  95.  
  96. PutLog:  procedure expose log script
  97. if arg(2) > GetClip('LOGLEVEL') & ~log then return 0
  98. address 'ROOFLOG' 'logline' left(time(),5) script': 'arg(1)
  99. address
  100. return 0
  101.  
  102. addslash:
  103. curr = arg(1)
  104. select
  105.     when right(curr, 1) = ":" then nop
  106.     when right(curr, 1) = "/" then nop
  107.         otherwise curr = curr"/"
  108. end
  109. return curr
  110.  
  111. /* a useful procedure by Walt Sullivan    */
  112. dequote:
  113.     parse arg thing
  114.     parse var thing '"' unq_thing '"'
  115.     if unq_thing ~= "" then return unq_thing
  116. return thing
  117. cleanup:
  118. return 0
  119. break_c:
  120. break_d:
  121.     PutLog('User abort',10,10)
  122.     call cleanup
  123.     exit 10
  124. novalue:
  125.         call template_oops "Novalue" sigl
  126. syntax:
  127.         call template_oops "Syntax(RC=" || RC || ")" sigl
  128. failure:
  129.         call template_oops "Failure(RC=" || RC || ")" sigl
  130. ioerr:
  131.         call template_oops "IOErr" sigl 
  132. halt:
  133.         call template_oops "Halt" sigl 
  134.  
  135. template_oops:
  136.         parse arg what badline
  137.         PutLog('Error Line:'badline what,10,10)
  138.         call cleanup
  139.         exit(40)
  140. /**/
  141.